A handheld, voice-control, raspberry-pi based game console
Designed By Tongyuan Liu, Shuzhe Liu.
Our project involves designing a handheld gaming console similar to the PSP and Gameboy, with games that can be controlled using our voice. Our plan is to create two games. The first game is reminiscent of Flappy Bird, where players control a character to avoid obstacles while being able to shoot bullets to destroy them. The second game is a side-scrolling game where players control a character moving continuously forward, avoiding falling off cliffs. The console's logic is depicted in the diagram below. In the menu interface, players can toggle sound controls, select games, and view the scoreboard. When a game ends, it transitions to the game over screen, where we've hidden an Easter egg. After the game over screen, it returns to the menu.
Game1: Flappy Fish
The first game, "Flappy Fish," is designed similarly to "Flappy Bird," featuring a character that can continuously jump to avoid obstacles. As an emergency evasion mechanism, a bullet-firing feature is added. The bullets are limited; players earn one bullet for every 300 points, starting with three bullets initially. As time (or score) increases, the difficulty level also increases.
We implement this game through the following steps:
Game2: Note Jump
The second game is a side-scrolling game called "Note Jump." In this game, players move on a horizontal platform and use jumping to avoid falling off cliffs. Similar to the design approach in Game 1, we also adopted a step-by-step design process. This approach made debugging easier:
Design Voice Control
We used the Sounddevice library to implement voice control in our project. This library can automatically detect connected audio devices and, through configuration, continuously receive and save external voice input. With this capability, we were able to easily capture audio through the microphone. We then calculated the volume of the sound using the norm function from NumPy and compared the obtained volume with a predefined threshold to determine whether an action should be executed.
One fundamental premise of voice control is that when a player encounters danger, they tend to become nervous and instinctively raise their voice. Therefore, we chose high volume levels as triggers for safety-related actions. The specific voice control logic for our games is as follows:
When designing the voice control for "Flappy Fish," we wanted the player to fire bullets when their voice exceeded a certain decibel level. However, in the initial version, shouting once would result in the firing of multiple bullets. To address this, we added logic similar to button debouncing to ensure that each loud shout only fired one bullet.
While PyAudio is a more commonly used library for audio processing, we initially attempted to use PyAudio to implement voice control. However, when we tried to run our code on a Raspberry Pi, we encountered some environment issues. During our troubleshooting efforts, we unfortunately had a significant impact on the system to the point where we couldn't even use the "startx" command to display the Raspberry Pi screen on a monitor. Fortunately, we had backups and were able to revert to a previous stable system. We decided to use the Sounddevice library as a replacement for PyAudio.
During the design process, we also encountered another issue. Initially, we wanted to use pitch to trigger avoidance actions because in times of crisis, a person's voice pitch tends to naturally rise. However, through testing, we found that this approach required a high level of precision in analyzing sound data, which our microphone did not support effectively. As a result, we opted to use higher volume levels as a substitute.
Design Scoreboard
When Voice Control is turned on, the Scoreboard displays the top five scores for each game achieved using voice control. When Voice Control is turned off, the Scoreboard shows the top five scores for each game achieved using button controls. This ensures fairness on the Scoreboard because obtaining high scores with voice control is generally more challenging than with button controls. Here's how we implemented this functionality:
Design Menu
We design the menu in the following steps:
Integration and Deisgn GPIO button control
In the initial stages of designing the game, we used simple rectangles to represent characters and objects within the game for ease of debugging. Later on, we use PiSKEL, an online pixel art design website, to design bullets, characters, and obstacles. Additionally, we used ChatGPT to generate background images, enhancing the visual aspects of the game.
Flappy Fish Background
Bullet
Fish Fish Player
Obstacle
Note Jump Background
Note Jump Player
Scoreboard Background
Menu Background
The Egg in the game
For future work, we can optimize the code structure by abstracting and encapsulating similar code into functions. Additionally, since our designer has a gaming console, we can add more games. We can also enhance the existing two games to make them more enjoyable, such as adding rewards like coins.
ChatGPT Our project has successfully implemented the expected functionality. Players can select and play two games from the menu interface, with both games supporting both sound and button controls. Each game also keeps track of the top five scores for both button and sound controls. This project incorporates various concepts from previous labs, such as auto-starting the games on boot and designing Easter eggs. Overall, we are very satisfied with the design of this gaming console.